package utils;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

import java.io.IOException;

public class HBaseConnectionUtils {


    private static Connection connection;
    private static Admin admin;

    static {
        Configuration config =  HBaseConfiguration.create();
        config.set("hbase.zookeeper.quorum","172.16.10.53");
        config.set("hbase.zookeeper.property.clientPort", "2181");
        try {
            connection = ConnectionFactory.createConnection(config);
            admin = getConnection().getAdmin();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static Connection getConnection(){
        return HBaseConnectionUtils.connection;
    }

    public static Admin getHBaseAdmin() {
        return HBaseConnectionUtils.admin;
    }


}
